# GNU makefile for chris's c++ testing and samples
# This will work on Linux or Windows, but probably
# only in the setup I have, however the examples are the
# main thing. 
#
# The Windows build assumes cygwin is in use and the path to
# cl $INCLUDE $LIB etc. are setup in it

OBJDIR = obj
EXE = ./cpp.exe

SRC = $(wildcard src/*.C)
OBJ := $(subst .C,.o,$(SRC))
OBJ := $(subst src/,$(OBJDIR)/,$(OBJ))

ifeq ($(wildcard c:/),c:/)
  # This appears to be a windows machine
  MC_TYPE=win
  COMPILE=cl -Z7 -DDEBUG -nologo -GF -EHs-c- -W3 -Zc:forScope -fp:precise -wd4530 \
-w14302 -arch:SSE2 -MDd -D_DEBUG -WX /Ob0 -I./include -c -Fo$@ -Tpd:$<
  LINK=link /out:$(EXE) /debug $(OBJ)

else
  # OK not windows, use linux
  MC_TYPE=linux
  COMPILE=g++  -Iinclude -g -c -std=c++0x -o $@ $< -DLINUX
  LINK=g++ -g $(OBJ) -o $(EXE)

endif 


$(EXE): $(OBJDIR) $(OBJ) 
	$(LINK)

run : $(EXE)
	$(EXE)

clean: 
	rm -rf $(OBJDIR) $(EXE)

$(OBJDIR) :
	mkdir -p $@

$(OBJDIR)/%.o : src/%.C
	$(COMPILE)
